<template>
  <li class="aui-list-item">
    <div class="aui-list-item">
      <div class="aui-media-list-item-inner">
        <div class="aui-list-item-media">
          <img v-lazy="orderItermInfor.goodsImg || 'static/image/demo2.png'">
        </div>
        <div class="aui-list-item-inner suggest" style="text-align: left;">
          <h3 style="font-size: 0.8rem">{{orderItermInfor.goodsName || " "}}</h3>
          <p class="cjy-show-detail" v-if="goodsPrice">
            {{orderInfor.orderType==2 ? '总积分：' : '总价：¥'}}{{  goodsPrice}}</p>
          <!--<p class="cjy-show-detail" v-if="orderItermInfor.goodsSpec">-->
          <!--{{orderItermInfor.goodsSpec != 0 ? '规格：' + orderItermInfor.goodsSpec : "&nbsp;"}}</p>-->

          <p class="cjy-show-detail" style="width: 100%" v-if=" orderItermInfor.goodsType != 7">
            {{'数量：' + goodsNum + goodsUnit}}</p>
          <p class="cjy-show-detail" style="width: 100%" v-if=" orderItermInfor.goodsType == 7">
            {{ '重量：' + goodsNum*1000 + goodsUnit}}</p>
        </div>
      </div>
    </div>
    <div class="aui-list-item">
      <div class="aui-list-item-inner">
        <div class="aui-list-item-text">
          <div class="aui-list-item-title">
            <span :style="{color: stateColor}" class="cjy-font-size">
               {{orderItermInfor.serviceStatus ? serviceStateName : "&nbsp;"}}
            </span>
          </div>


          <div class="edit_address" style="margin-bottom:0;margin-right:15px;border-bottom:0;padding:0">

            <div v-if="serviceState == 4 && orderItermInfor.serviceType == 2 && false"
                 class="aui-btn aui-btn-outlined aui-btn-danger" @click="goToUpdateMassage">
              上传退货信息
            </div>

            <div v-if="orderType == 0" class="aui-btn aui-btn-outlined aui-btn-danger" @click="goToAfterSale">
              申请售后
            </div>

            <div v-if="orderType == 1" id="return_details" class="cjy-bottom-style"
                 @click="goToDetail">
              查看详情
            </div>
          </div>
        </div>
      </div>
    </div>
  </li>

</template>

<script>
  import {translatePrice} from "@/utils/TranslatePriceC"

  export default {
    data() {
      return {}
    },
    beforeCreate() {
      this.orderSubNo = this.$route.query.orderSubNo || ""
    },
    created() {
      console.log(this.orderItermInfor,"this.orderItermInfor1336")
      // console.log(this.orderSubNo,"this.orderSubNo99999")
    },
    methods: {
      //上传退货信息
      goToUpdateMassage() {
        this.$router.replace({path: "saleReturn", query: this.upDataInfor})
      },
      //去到详情页面
      goToDetail() {
        this.$router.replace({path: "afterSaleDetail", query: this.routerInfor})
      },
      //去到退货界面
      goToAfterSale() {
        this.$router.replace({path: "afterSale", query: this.routerInfor})
      }
    },
    computed: {

      goodsUnit() {
        var goodsUnit = this.orderItermInfor.mallUnit?this.orderItermInfor.mallUnit:this.orderItermInfor.goodsUnit;
        if (this.orderItermInfor.goodsType == 7) {
          goodsUnit = 'g'
        }
        return goodsUnit
      },
      //订单类型
      orderType() {
        return this.$store.state.cjy.classifyIndex
      },
      //售后详情传递信息
      routerInfor() {
        var routerInfor = Object.assign(this.orderItermInfor, this.orderInfor)
        routerInfor.orderServeList = routerInfor.orderServeList ? JSON.stringify(routerInfor.orderServeList) : "";
        routerInfor.orderSubNo = this.orderSubNo
        for (var key in routerInfor) {
          routerInfor[key] = routerInfor[key] || routerInfor[key] == 0 ? routerInfor [key] : ""
        }

        return routerInfor
      },
      //上传退货信息
      upDataInfor() {
        var routerInfor = this.routerInfor
        var upDataInfor = {
          userPhone: routerInfor.userPhone || "",//电话号码
          orderNo: routerInfor.orderNo || "", // 订单编号
          serviceNo: routerInfor.serviceNo || "", // 售后单编号
          goodsId: routerInfor.goodsId || "", // 商品Id
          goodsName: routerInfor.goodsName || "", //商品名称
          goodsNum: routerInfor.applyQuantity || "", //退货数量
          orderSubNo: this.orderSubNo
        }

        return upDataInfor
      },
      //售后状态
      serviceState() {
        var serviceState = this.orderItermInfor.serviceStatus || 0
        return serviceState
      },
      //售后名称
      serviceStateName() {
        var serviceState = this.orderItermInfor.serviceStatus || 0
        var serviceStateName = ''
        switch (serviceState) {
          case 5:
            serviceStateName = '审核拒绝';
            break;

          case 1:
            ;
          case 2:
            ;
          case 4:
            ;
          case 7:
            ;
          case 9:
            ;
          case 14:
            serviceStateName = '审核中';
            break;
          case 3:
            ;
          case 8:
            ;
          case 10:
            ;
          case 15:
            serviceStateName = '审核中';
            break;
          case 11:
            serviceStateName = '退款中';
            break;
            ;
          case 12:
            serviceStateName = '退款成功';
            break;
            ;
          case 13:
            serviceStateName = '退款失败';
            break;
            ;
          default:
            serviceStateName = '';
        }

        return serviceStateName
      },
      //文字显示的颜色
      stateColor() {
        var stateColorList = new Map([
          [0, "black"],
          [1, "#0f8de0"],//审核中
          [2, "#0f8de0"],//售后申请成功
          [3, "#e51c23"],//售后申请失败
          [4, "#0f8de0"],//运营审核通过
          [5, "#e51c23"],//运营审核拒绝
          [6, "#0f8de0"],//退货申请提交
          [7, "#0f8de0"],//退货审核通过
          [8, "#e51c23"],//退货审核拒绝
          [9, "#0f8de0"],//财务审核成功
          [10, "#e51c23"],//财务审核失败
          [11, "#0f8de0"],//退款中
          [12, "#0f8de0"],//退款成功
          [13, "#e51c23"],//退款失败
          [14, "#0f8de0"],//服务商审核通过
          [15, "#e51c23"]// 服务商审核拒绝
        ])
        var serviceState = parseInt(this.serviceState)
        return stateColorList.get(serviceState) || "#0f8de0"
      },

      // 数量展示
      goodsNum() {
        var orderInfor = this.orderItermInfor
        var goodsType = orderInfor.goodsType
        if (goodsType == 7) {
          return orderInfor.outGoodsNum || orderInfor.actualWeight
        } else {
          return orderInfor.applyQuantity || orderInfor.outGoodsNum || 1

        }

      },
      goodsPrice() {
        var orderInfor = this.orderItermInfor
        var goodsType = orderInfor.goodsType
        var goodsPrice
        var goodsNum = orderInfor.applyQuantity || orderInfor.actualWeight
        var totalPrice = orderInfor.realTotalMoney
//        var realPrice = orderInfor.realPrice
//        if (goodsType == 6 && orderInfor.outGoodsNum) {
//          realPrice = this.orderItermInfor.totalMoney / orderInfor.outGoodsNum
//          realPrice = translatePrice(realPrice)
//        }
        goodsPrice = totalPrice || orderInfor.goodsDealPrice * goodsNum
        if (goodsPrice == 'undefined') {
          return 0
        }else if(this.orderInfor.orderType==2){
        	return goodsPrice || 0
        }
        return parseFloat(goodsPrice || 0).toFixed(2)
      }
    },


    props: {
      orderInfor: {
        type: Object,
        default: () => {
          return {
            orderNo: "000000000000",
            createTime: "yy.MM.dd hh:mm",
          }
        }
      }
      ,
      orderItermInfor: {
        type: Object,
        default: () => {
          return {}
        }
      }

    }
  }
</script>

<style scoped>

  @media screen and (max-width: 322px) {
    .aui-btn {
      height: 1.4rem !important;
      line-height: 1.4rem;
      padding-left: 0.3rem;
      padding-right: 0.3rem;
      font-size: 10px !important;
    }

    .cjy-list-item-title {
      font-size: 18px !important;
    }

    .cjy-font-size {

      font-size: 12px !important;
    }
  }

  .cjy-show-detail {
    width: 50%;
    float: left;
    font-size: 0.65rem !important;
  }

  .cjy-bottom-style {
    font-size: 0.7rem;
    position: relative;
    color: #444444;
    background-color: inherit;
    border: 1px solid #E0E0E0;
    padding: 0 0.6rem;
    height: 1.5rem;
    line-height: 1.5rem;
    border-radius: 0.2rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    vertical-align: middle;
    font-family: inherit;
    text-decoration: none;
    text-align: center;
    display: inline-block;

  }
</style>
